package com.ruoyi.web.controller.app;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.project.domain.OrderDispatch;
import com.ruoyi.project.domain.OrderPreOrder;
import com.ruoyi.project.domain.OrderReport;
import com.ruoyi.project.domain.OrderUpdateLog;
import com.ruoyi.project.service.IOrderDispatchService;
import com.ruoyi.project.service.IOrderPreOrderService;
import com.ruoyi.project.service.IOrderReportService;
import com.ruoyi.project.service.IOrderUpdateLogService;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api("订单管理")
@Controller
@RequestMapping("/api/order")
public class OrderController{

	@Autowired
	private IOrderPreOrderService orderPreOrderService;

	@Autowired
	private IOrderDispatchService orderDispatchService;

	@Autowired
	private IOrderUpdateLogService orderUpdateLogService;

	@Autowired
	private ISysUserService sysUserService;
	@Autowired
	private IOrderReportService orderReportService;

	@ApiOperation("项目经理-可派单/已派单/已退回")
	@ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "Long"), @ApiImplicitParam(name = "status", value = "状态：（0：可派单；1：已派单；2：已退回）", required = true, dataType = "String")})
	@GetMapping("/getPreOrderList")
	@ResponseBody
	public AjaxResult getPreOrderList(Long userId, String status) throws Exception{
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("userId", userId != null ? userId : ShiroUtils.getSysUser().getUserId());
		if("0".equals(status)){
			status = "0,2";// 可派单查询：可派单与已退回的数据
		}
		paramMap.put("status", status);
		return AjaxResult.success(orderPreOrderService.getPreOrderList(paramMap));
	}

	@ApiOperation("项目经理-可派单-派单")
	@ApiImplicitParams({@ApiImplicitParam(name = "preId", value = "可派单表主键Id", required = true, dataType = "String"), @ApiImplicitParam(name = "processId", value = "合同里程碑Id", required = true, dataType = "String"),
			@ApiImplicitParam(name = "orderName", value = "派单名称，默认为（合同名称+里程碑名称）", required = true, dataType = "String"), @ApiImplicitParam(name = "receiveUserId", value = "指派接收人Id", required = true, dataType = "String"),
			@ApiImplicitParam(name = "receiveUserName", value = "指派接收人姓名", required = true, dataType = "String"), @ApiImplicitParam(name = "dispatchUserId", value = "派单人id", required = false, dataType = "String"),
			@ApiImplicitParam(name = "dispatchUserName", value = "派单人姓名", required = false, dataType = "String"), @ApiImplicitParam(name = "collectibleRatio", value = "实际回款百分比", required = false, dataType = "Double")

	})
	@PostMapping("/dispatchOrder")
	@ResponseBody
	@Transactional
	public AjaxResult dispatchOrder(String preId, String processId, String orderName, String receiveUserId, String receiveUserName, String dispatchUserId, String dispatchUserName, Double collectibleRatio) throws Exception{

		// 必填项验证
		if(preId == null){
			throw new BusinessException("可派单表主键Id不能为空");
		}
		if(processId == null){
			throw new BusinessException("合同里程碑Id不能为空");
		}
		if(StringUtils.isEmpty(orderName)){
			throw new BusinessException("派单名称不能为空");
		}
		if(receiveUserId == null){
			throw new BusinessException("指派接收人Id不能为空");
		}
		if(StringUtils.isEmpty(receiveUserName)){
			throw new BusinessException("指派接收人姓名不能为空");
		}
		if(collectibleRatio == null){
			throw new BusinessException("实际回款百分比不能为空");
		}

		OrderPreOrder orderPreOrder = orderPreOrderService.selectOrderPreOrderById(Long.parseLong(preId));

		// 插入派单表
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderName(orderName);
		od.setConProcessId(Long.parseLong(processId));
		od.setDispatchUserId(dispatchUserId != null ? Long.parseLong(dispatchUserId) : ShiroUtils.getSysUser().getUserId());
		od.setDispatchUserName(dispatchUserName != null ? dispatchUserName : ShiroUtils.getSysUser().getUserName());
		od.setDispatchTime(now);
		od.setReceiveUserId(Long.parseLong(receiveUserId));
		od.setReceiveUserName(receiveUserName);
		od.setCreateBy(dispatchUserName);
		od.setCreateTime(now);
		od.setCollectibleRatio(collectibleRatio); // 实际回款百分比
		od.setPreOrderId(Long.parseLong(preId));
		od.setOrderStatus("0");
		int a = orderDispatchService.insertOrderDispatch(od);
		// 修改可派单表状态
		if(a > 0){
			OrderPreOrder opo = new OrderPreOrder();
			opo.setId(Long.parseLong(preId));
			// 实际回款百分比与可催款百分比相同时，设置已派单状态，否则保留可派单数据继续派单
			if(orderPreOrder.getCollectibleRatio() == collectibleRatio){
				opo.setStatus("1");
			}
			opo.setCollectibleRatio(orderPreOrder.getCollectibleRatio() - collectibleRatio); // 计算剩余可派单回款百分比
			orderPreOrderService.updateOrderPreOrder(opo);
		}
		return AjaxResult.success();
	}

	@ApiOperation("项目经理-手工维护需派单合同款项-加入派单池")
	@ApiImplicitParams({@ApiImplicitParam(name = "processId", value = "合同里程碑Id", required = true, dataType = "String"), @ApiImplicitParam(name = "orderName", value = "派单名称，默认为（合同名称+里程碑名称）", required = true, dataType = "String"),
			@ApiImplicitParam(name = "dispatchUserId", value = "派单人id", required = false, dataType = "String"), @ApiImplicitParam(name = "dispatchUserName", value = "派单人姓名", required = false, dataType = "String"),})
	@PostMapping("/joinPreOrder")
	@ResponseBody
	@Transactional
	public AjaxResult joinPreOrder(String processId, String orderName, String dispatchUserId, String dispatchUserName) throws Exception{
		// 必填项验证
		if(processId == null){
			throw new BusinessException("合同里程碑Id不能为空");
		}
		if(StringUtils.isEmpty(orderName)){
			throw new BusinessException("派单名称不能为空");
		}

		// 用户信息校验
		if(dispatchUserId == null){
			SysUser currentUser = ShiroUtils.getSysUser();
			// 获取当前的用户名称
			dispatchUserId = currentUser.getUserId().toString();
			dispatchUserName = currentUser.getUserName();
		}
		OrderPreOrder opo = new OrderPreOrder();
		opo.setConProcessId(Long.parseLong(processId));
		opo.setStatus("0");
		List<OrderPreOrder> preOrderList = orderPreOrderService.selectOrderPreOrderList(opo);
		if(preOrderList != null && preOrderList.size() > 0){
			return AjaxResult.warn("此合同已加入派单池。");
		}

		opo.setOrderName(orderName);
		opo.setDispatchUserId(dispatchUserId);
		opo.setDispatchUserName(dispatchUserName);
		opo.setCreateBy(dispatchUserName);
		opo.setCreateTime(new Date());
		opo.setIsDelete("0");
		return AjaxResult.success(orderPreOrderService.insertOrderPreOrder(opo));
	}

	@ApiOperation("回款负责人-我的接单")
	@ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "String"), @ApiImplicitParam(name = "status", value = "订单状态ID", required = true, dataType = "String"),
			@ApiImplicitParam(name = "contractName", value = "合同名称", required = false, dataType = "String")})
	@GetMapping("/getMyOrderList")
	@ResponseBody
	public AjaxResult getMyPendingOrderList(String userId, String status, String contractName) throws Exception{
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("userId", userId != null ? userId : ShiroUtils.getSysUser().getUserId());
		paramMap.put("status", status);
		paramMap.put("contractName", contractName);
		return AjaxResult.success(orderDispatchService.getMyOrderList(paramMap));
	}

	@ApiOperation("回款负责人-待接单-接单")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long")})
	@PostMapping("/receiveOrder")
	@ResponseBody
	@Transactional
	public AjaxResult receiveOrder(String orderId) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}
		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		Long userId = null;
		if(currentUser != null){
			userName = currentUser.getUserName();
			userId = currentUser.getUserId();
		}
		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		// 修改派单表状态
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderId(Long.parseLong(orderId));
		od.setUpdateBy(userName);
		od.setUpdateTime(now);
		od.setOrderStatus("1");
		od.setReceiveTime(now);
		orderDispatchService.updateOrderDispatch(od);

		// 插入操作日志
		OrderUpdateLog oul = new OrderUpdateLog();
		oul.setConOrderId(Long.parseLong(orderId));
		oul.setParamsName("order_status");
		oul.setParamsDesc("接单");
		oul.setBeforeValue(orderDispath.getOrderStatus());
		oul.setNowValue("1");
		oul.setIsAuto("0");
		oul.setChangeUserId(userId);
		oul.setChangeUserName(userName);
		oul.setCreateBy(userName);
		oul.setCreateTime(now);
		orderUpdateLogService.insertOrderUpdateLog(oul);
		return AjaxResult.success();
	}

	@ApiOperation("回款负责人-待接单-退单")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long"), @ApiImplicitParam(name = "backDesc", value = "退单原因", required = true, dataType = "String")})
	@PostMapping("/rejectOrder")
	@ResponseBody
	@Transactional
	public AjaxResult rejectOrder(String orderId, String backDesc) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}
		// 必填项验证
		if(backDesc == null){
			throw new BusinessException("退单原因不能为空");
		}

		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		Long userId = null;
		if(currentUser != null){
			userName = currentUser.getUserName();
			userId = currentUser.getUserId();
		}

		// 当前订单
		OrderDispatch oldOrderDispatch = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		// 当前派单
		OrderPreOrder oldOrderPreOrder = orderPreOrderService.selectOrderPreOrderById(orderDispath.getPreOrderId());

		// 修改派单表状态
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderId(Long.parseLong(orderId));
		od.setUpdateBy(userName);
		od.setUpdateTime(now);
		od.setOrderStatus("2");
		orderDispatchService.updateOrderDispatch(od);

		// 修改可派单表状态
		OrderPreOrder orderPreOrder = new OrderPreOrder();
		orderPreOrder.setStatus("2");
		orderPreOrder.setId(orderDispath.getPreOrderId());
		orderPreOrder.setBackDesc(backDesc);
		orderPreOrder.setBackTime(new Date());
		// 如果派单池中剩余回款百分比为0，则将退单百分比还给派单池。 如果不相同，则相加后再修改派单池中剩余回款百分比
		if(oldOrderPreOrder.getCollectibleRatio() == 0){
			orderPreOrder.setCollectibleRatio(oldOrderDispatch.getCollectibleRatio());
		}else{
			orderPreOrder.setCollectibleRatio(oldOrderDispatch.getCollectibleRatio() + oldOrderPreOrder.getCollectibleRatio());
		}
		orderPreOrderService.updateOrderPreOrder(orderPreOrder);

		// 插入操作日志
		OrderUpdateLog oul = new OrderUpdateLog();
		oul.setConOrderId(Long.parseLong(orderId));
		oul.setParamsName("order_status");
		oul.setParamsDesc("退单");
		oul.setBeforeValue(orderDispath.getOrderStatus());
		oul.setNowValue("0");
		oul.setIsAuto("0");
		oul.setChangeUserId(userId);
		oul.setChangeUserName(userName);
		oul.setCreateBy(userName);
		oul.setCreateTime(now);
		orderUpdateLogService.insertOrderUpdateLog(oul);
		return AjaxResult.success();
	}

	@ApiOperation("回款负责人-待维护回款计划-维护回款计划")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long"), @ApiImplicitParam(name = "planTime", value = "回款计划时间", required = true, dataType = "Date")})
	@PostMapping("/waitMaintainPlan")
	@ResponseBody
	@Transactional
	public AjaxResult waitMaintainPlan(String orderId, Date planTime) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}
		if(planTime == null){
			throw new BusinessException("回款计划时间不能为空");
		}

		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		Long userId = null;
		if(currentUser != null){
			userName = currentUser.getUserName();
			userId = currentUser.getUserId();
		}

		// 修改派单表状态
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderId(Long.parseLong(orderId));
		od.setUpdateBy(userName);
		od.setUpdateTime(now);
		od.setOrderStatus("3"); // 设置成待维护回款计划状态
		od.setPlanTime(planTime);
		orderDispatchService.updateOrderDispatch(od);

		// 插入操作日志
		OrderUpdateLog oul = new OrderUpdateLog();
		oul.setConOrderId(Long.parseLong(orderId));
		oul.setParamsName("order_status");
		oul.setParamsDesc("维护回款计划");
		oul.setBeforeValue(orderDispath.getOrderStatus());
		oul.setNowValue("3");
		oul.setIsAuto("0");
		oul.setChangeUserId(userId);
		oul.setChangeUserName(userName);
		oul.setCreateBy(userName);
		oul.setCreateTime(now);
		orderUpdateLogService.insertOrderUpdateLog(oul);
		return AjaxResult.success();
	}

	@ApiOperation("回款负责人-待维护双周状态-维护状态报告-提交")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long"), @ApiImplicitParam(name = "feedbackStatus", value = "状态(0：绿；1：黄；2：红)", required = true, dataType = "String"),
			@ApiImplicitParam(name = "suggestion", value = "状态报告原因", required = false, dataType = "String")})
	@PostMapping("/maintainStatusReport")
	@ResponseBody
	@Transactional
	public AjaxResult maintainStatusReport(String orderId, String feedbackStatus, String suggestion) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}
		if(feedbackStatus == null){
			throw new BusinessException("状态不能为空");
		}

		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		if(currentUser != null){
			userName = currentUser.getUserName();
		}

		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		// 插入状态报告维护记录
		OrderReport orderReport = new OrderReport();
		orderReport.setOrderId(Long.parseLong(orderId));
		orderReport.setFeedbackStatus(Integer.parseInt(feedbackStatus));
		orderReport.setFeedbackStatusTime(new Date());
		orderReport.setSuggestion(suggestion);
		orderReport.setCreateBy(userName);
		orderReport.setCreateTime(new Date());
		orderReportService.insertOrderReport(orderReport);
		return AjaxResult.success();
	}

	@ApiOperation("回款负责人-待维护双周状态-办结")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long"), @ApiImplicitParam(name = "userId", value = "公司PMO用户ID", required = true, dataType = "String")})
	@PostMapping("/finishFlow")
	@ResponseBody
	@Transactional
	public AjaxResult finishFlow(String orderId, String userId) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}
		if(userId == null){
			throw new BusinessException("部门PMO不能为空");
		}

		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		Long currentUserId = null;
		if(currentUser != null){
			currentUserId = currentUser.getUserId();
			userName = currentUser.getUserName();
		}

		// 修改派单表状态
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderId(Long.parseLong(orderId));
		od.setUpdateBy(userName);
		od.setUpdateTime(now);
		od.setOrderStatus("4"); // 设置成待维护回款计划状态
		od.setCompanyApprovalUserId(Long.parseLong(userId));
		// 根据公司PMO用户ID查询用户名称
		SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userId));
		od.setCompanyApprovalUserName(sysUser.getUserName());
		orderDispatchService.updateOrderDispatch(od);

		// 插入操作日志
		OrderUpdateLog oul = new OrderUpdateLog();
		oul.setConOrderId(Long.parseLong(orderId));
		oul.setParamsName("order_status");
		oul.setParamsDesc("办结");
		oul.setBeforeValue(orderDispath.getOrderStatus());
		oul.setNowValue("4");
		oul.setIsAuto("0");
		oul.setChangeUserId(currentUserId);
		oul.setChangeUserName(userName);
		oul.setCreateBy(userName);
		oul.setCreateTime(now);
		orderUpdateLogService.insertOrderUpdateLog(oul);
		return AjaxResult.success();
	}

	@ApiOperation("回款负责人-待维护双周状态-办结-选择公司PMO(暂时不通过角色查询，现查询指定一个用户。)")
	@ApiImplicitParams({})
	@PostMapping("/companyPMOUser")
	@ResponseBody
	@Transactional
	public AjaxResult deptPMOUser() throws Exception{
		Map<String, Object> paramsMap = new HashMap<>();
		paramsMap.put("status", "0"); // 获取状态正常的用户
		paramsMap.put("userId", "582"); // 暂时设定为李梓铭一个用户为公司PMO
		List<SysUser> sysUserList = sysUserService.selectUserByParams(paramsMap);
		return AjaxResult.success(sysUserList);
	}

	@ApiOperation("公司PMO-办结审批列表")
	@ApiImplicitParams({@ApiImplicitParam(name = "companyApprovalUserId", value = "公司PMO用户ID", required = false, dataType = "String")})
	@GetMapping("/getApprovalOrderList")
	@ResponseBody
	public AjaxResult getApprovalOrderList(String companyApprovalUserId) throws Exception{
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("companyApprovalUserId", companyApprovalUserId);
		paramMap.put("status", "4"); // 办结审批流程中
		return AjaxResult.success(orderDispatchService.getMyOrderList(paramMap));
	}

	@ApiOperation("公司PMO-审批同意")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long")})
	@PostMapping("/companyApproval")
	@ResponseBody
	@Transactional
	public AjaxResult companyApproval(String orderId) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}

		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		Long userId = null;
		if(currentUser != null){
			userId = currentUser.getUserId();
			userName = currentUser.getUserName();
		}

		// 修改派单表状态
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderId(Long.parseLong(orderId));
		od.setUpdateBy(userName);
		od.setUpdateTime(now);
		od.setOrderStatus("5"); // 设置成已办结
		orderDispatchService.updateOrderDispatch(od);

		// 插入操作日志
		OrderUpdateLog oul = new OrderUpdateLog();
		oul.setConOrderId(Long.parseLong(orderId));
		oul.setParamsName("order_status");
		oul.setParamsDesc("公司PMO审批同意");
		oul.setBeforeValue(orderDispath.getOrderStatus());
		oul.setNowValue("5");
		oul.setIsAuto("0");
		oul.setChangeUserId(userId);
		oul.setChangeUserName(userName);
		oul.setCreateBy(userName);
		oul.setCreateTime(now);
		orderUpdateLogService.insertOrderUpdateLog(oul);
		return AjaxResult.success();
	}

	@ApiOperation("公司PMO-审批退回")
	@ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单Id", required = true, dataType = "Long")})
	@PostMapping("/companyApprovalBack")
	@ResponseBody
	@Transactional
	public AjaxResult companyApprovalBack(String orderId) throws Exception{
		// 必填项验证
		if(orderId == null){
			throw new BusinessException("订单Id不能为空");
		}

		// 校验订单是否存在
		OrderDispatch orderDispath = orderDispatchService.selectOrderDispatchById(Long.parseLong(orderId));
		if(orderDispath == null){
			throw new BusinessException("此订单不存在");
		}

		SysUser currentUser = ShiroUtils.getSysUser();
		String userName = "";
		Long userId = null;
		if(currentUser != null){
			userId = currentUser.getUserId();
			userName = currentUser.getUserName();
		}

		// 修改派单表状态
		OrderDispatch od = new OrderDispatch();
		Date now = new Date();
		od.setOrderId(Long.parseLong(orderId));
		od.setUpdateBy(userName);
		od.setUpdateTime(now);
		od.setOrderStatus("3"); // 设置成双周状态
		orderDispatchService.updateOrderDispatch(od);

		// 插入操作日志
		OrderUpdateLog oul = new OrderUpdateLog();
		oul.setConOrderId(Long.parseLong(orderId));
		oul.setParamsName("order_status");
		oul.setParamsDesc("公司PMO审批退回");
		oul.setBeforeValue(orderDispath.getOrderStatus());
		oul.setNowValue("3");
		oul.setIsAuto("0");
		oul.setChangeUserId(userId);
		oul.setChangeUserName(userName);
		oul.setCreateBy(userName);
		oul.setCreateTime(now);
		orderUpdateLogService.insertOrderUpdateLog(oul);
		return AjaxResult.success();
	}

}
